package com.mvvm.ktnet.ui.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.rxLifeScope
import com.alibaba.fastjson.JSON
import com.drake.logcat.LogCat
import com.drake.tooltip.toast
import com.mvvm.ktnet.base.viewmodel.BaseViewModel
import com.mvvm.ktnet.base.viewmodel.LoadingType
import com.mvvm.ktnet.databind.livedata.StringLiveData
import com.mvvm.ktnet.entity.TestBean
import com.mvvm.ktnet.ext.LogJsonString
import com.mvvm.ktnet.ext.launchEmpty
import com.mvvm.ktnet.http.base.UrlPath
import nethttp.RxHttp
import nethttp.toResponseData
import rxhttp.async
import rxhttp.onErrorReturn
import rxhttp.toStr

/**
 *
 * @ProjectName:    KtNet
 * @Package:        com.mvvm.ktnet.ui.viewmodel
 * @ClassName:      MainViewModel
 * @Description:     java类作用描述
 * @Author:         Alex
 * @CreateDate:     2020/11/12 17:28
 * @UpdateUser:     更新者：
 * @UpdateDate:     2020/11/12 17:28
 * @UpdateRemark:   更新说明：
 * @Version:        1.0
 */
class MainViewModel : BaseViewModel() {

    val liveString = MutableLiveData<TestBean>()

    fun getTestString() = launchEmpty(
        {
            val test = RxHttp.postJson(UrlPath)
                .add("apiName", "getTodayVideoLive")
                .add("bid", "com.kansaishi.live.debug_kaisaishi")
                .add("channel", 2001001)
                .add("category", 0)
                .add("from", 1)
                .add("vt", "3.1.01")
                .toResponseData<TestBean>()
                .async(this)

            LogCat.e(JSON.toJSONString(test.await()))


            liveString.postValue(test.await())
        },{



        },{


        },loadingType=LoadingType.LOADING_PAGE
    )

}
